Methods and apparatus for optimal journaling for continuous data replication

ABSTRACT

Methods and systems for continuous data replication, including receiving a write transaction from a production site, the write transaction including raw data (RWNEW), a size indicator (SZ 1 ) for the size of the raw data, and a start address (ADD 1 ) for writing the raw data, copying the raw data (RWNEW) into a first journal data stream at a current journal address (JADD 1 ), and copying the size indicator (SZ 1 ), the start address (ADD 1 ) and the journal address (JADD 1 ) into a first journal meta-data stream.

BACKGROUND

Computer data is vital to today's organizations, and a significant partof protection against disasters is focused on data protection. Assolid-state memory has advanced to the point where cost of memory hasbecome a relatively insignificant factor, organizations can afford tooperate with systems that store and process terabytes of data.

Conventional data protection systems include tape backup drives, forstoring organizational production site data on a periodic basis. Suchsystems suffer from several drawbacks. First, they require a systemshutdown during backup, since the data being backed up cannot be usedduring the backup operation. Second, they limit the points in time towhich the production site can recover. For example, if data is backed upon a daily basis, there may be several hours of lost data in the eventof a disaster. Third, the data recovery process itself takes a longtime.

Another conventional data protection system uses data replication, bycreating a copy of the organization's production site data on asecondary backup storage system, and updating the backup with changes.The backup storage system may be situated in the same physical locationas the production storage system, or in a physically remote location.Data replication systems generally operate either at the applicationlevel, at the file system level, or at the data block level.

Current data protection systems try to provide continuous dataprotection, which enable the organization to roll back to any specifiedpoint in time within a recent history. Continuous data protectionsystems aim to satisfy two conflicting objectives, as best as possible;namely, (i) minimize the down time, in which the organization productionsite data is unavailable, during a recovery, and (ii) enable recovery asclose as possible to any specified point in time within a recenthistory.

Continuous data protection typically uses a technology referred to as“journaling,” whereby a log is kept of changes made to the backupstorage. During a recovery, the journal entries serve as successive“undo” information, enabling rollback of the backup storage to previouspoints in time. Journaling was first implemented in database systems,and was later extended to broader data protection.

One challenge to continuous data protection is the ability of a backupsite to keep pace with the data transactions of a production site,without slowing down the production site. The overhead of journalinginherently requires several data transactions at the backup site foreach data transaction at the production site. As such, when datatransactions occur at a high rate at the production site, the backupsite may not be able to finish backing up one data transaction beforethe next production site data transaction occurs. If the production siteis not forced to slow down, then necessarily a backlog of un-logged datatransactions may build up at the backup site. Without being able tosatisfactorily adapt dynamically to changing data transaction rates, acontinuous data protection system chokes and eventually forces theproduction site to shut down.

SUMMARY

The present invention concerns methods and systems for providingcontinuous data replication under dynamically changing I/O rates, byimplementing an optimized asynchronous journaling policy that adaptsdynamically to changing data transaction rates. A nominal journalingpolicy operates asynchronously, allowing production site datatransactions to proceed prior to completion of logging of previous datatransactions. The nominal journaling policy changes to an acceleratedpolicy when a backlog of data transactions exceeds a predetermined size,and changes back to the nominal policy when the backlog is suitablyrelieved. The nominal journaling policy includes five stages of I/O, andthe accelerated journal policy omits two of the five stages.

In addition, the present invention uses a near real-time journalingpolicy, when the data transaction rate at the production site is slowenough to enable the backup site to keep pace without need for a journalbacklog buffer. The near real-time policy is used until the datatransaction rate increases to the point that the journal backlog bufferis necessary.

There is thus provided in accordance with an embodiment of the presentinvention a method for continuous data replication, including receivinga write transaction from a production site, the write transactionincluding raw data, designated RWNEW, a size indicator for the size ofthe raw data, designated SZ1, and a start address for writing the rawdata, designated ADD1, copying raw data RWNEW into a first journal datastream, starting at a current journal address, designated JADD1, andcopying size indicator SZ1, start address ADD1 and journal address JADD1into a first journal meta-data stream, at the end of the first journalmeta-data stream.

There is moreover provided in accordance with an embodiment of thepresent invention a method for continuous data replication, includingreceiving a write transaction from a production site, the writetransaction including raw data, designated RWNEW, a size indicator forthe size of the raw data, designated SZ, and a start address for writingthe raw data, designated ADD, reading raw data, designated RWOLD, from astorage unit beginning at start address ADD and extending to the size ofsize indicator SZ, copying raw data RWOLD to a journal data stream at acurrent journal address, designated JADD, copying size indicator SZ,start address ADD, and journal address JADD into a journal meta-datastream, at the end of the journal meta-data stream, and copying raw dataRWNEW to the storage unit, beginning at start address ADD.

There is further provided in accordance with an embodiment of thepresent invention a method for continuous data replication, includingreceiving a plurality of write transactions from a production site, eachwrite transaction including raw data, designated RWNEW, a size indicatorfor the size of the raw data, designated SZ1, and a start address forwriting the raw data, designated ADD1, if the plurality of writetransactions are received at a high I/O rate, then copying raw dataRWNEW into a first journal data stream, starting at a current journaladdress, designated JADD1, and copying size indicator SZ1, start addressADD1 and journal address JADD1 into a first journal meta-data stream, atthe end of the first journal meta-data stream, else reading raw data,designated RWOLD, from a storage unit beginning at start address ADD1and extending to the size of size indicator SZ1, copying raw data RWOLDto a second journal data stream at a current journal address, designatedJADD2, copying size indicator SZ1, start address ADD1, and journaladdress JADD2 into a second journal meta-data stream, at the end of thesecond journal meta-data stream, and copying raw data RWNEW to thestorage unit, beginning at start address ADD1.

There is yet further provided in accordance with an embodiment of thepresent invention a computer-readable storage medium storing programcode for causing a computing device to receive a write transaction froma production site, the write transaction including raw data, designatedRWNEW, a size indicator for the size of the raw data, designated SZ1,and a start address for writing the raw data, designated ADD1, copy rawdata RWNEW into a first journal data stream, starting at a currentjournal address, designated JADD1, and copy size indicator SZ1, startaddress ADD1 and journal address JADD1 into a first journal meta-datastream, at the end of the first journal meta-data stream.

There is additionally provided in accordance with an embodiment of thepresent invention a computer-readable storage medium storing programcode for causing a computing device to receive a write transaction froma production site, the write transaction including raw data, designatedRWNEW, a size indicator for the size of the raw data, designated SZ, anda start address for writing the raw data, designated ADD, read raw data,designated RWOLD, from a storage unit beginning at start address ADD andextending to the size of size indicator SZ, copy raw data RWOLD to ajournal data stream at a current journal address, designated JADD, copysize indicator SZ, start address ADD, and journal address JADD into ajournal meta-data stream, at the end of the journal meta-data stream,and copy raw data RWNEW to the storage unit, beginning at start addressADD.

There is moreover provided in accordance with an embodiment of thepresent invention a computer-readable storage medium storing programcode for causing a computing device to receive a plurality of writetransactions from a production site, each write transaction includingraw data, designated RWNEW, a size indicator for the size of the rawdata, designated SZ1, and a start address for writing the raw data,designated ADD1, if the plurality of write transactions are received ata high I/O rate, then copy raw data RWNEW into a first journal datastream, starting at a current journal address, designated JADD1, andcopy size indicator SZ1, start address ADD1 and journal address JADD1into a first journal meta-data stream, at the end of the first journalmeta-data stream, else read raw data, designated RWOLD, from a storageunit beginning at start address ADD1 and extending to the size of sizeindicator SZ1, copy raw data RWOLD to a second journal data stream at acurrent journal address, designated JADD2, copy size indicator SZ1,start address ADD1, and journal address JADD2 into a second journalmeta-data stream, at the end of the second journal meta-data stream, andcopy raw data RWNEW to the storage unit, beginning at start addressADD1.

There is further provided in accordance with an embodiment of thepresent invention a method for continuous data replication, includingreceiving a plurality of write transactions from a data production site,for application at a data backup site, dynamically selecting one of aplurality of journaling processes based on at least one processing statetransition rule, wherein each of the plurality of journaling processescontrols the queuing, recording and application of write transactionsreceived at the backup site, and wherein each of the at least oneprocessing state transition rule relates directly or indirectly to ratesof incoming write transactions at the data backup site, temporarilyqueuing write transactions at the backup site within a queue, inaccordance with the selected journaling process, recording writetransactions at the backup site, for data recovery purposes, inaccordance with the selected journaling process, and applying the writetransactions at the backup site, in accordance with the selectedjournaling process.

There is yet further provided in accordance with an embodiment of thepresent invention a system for continuous data replication, including areceiver for receiving a plurality of write transactions from a dataproduction site, for application at a data backup site, a state machinefor dynamically selecting one of a plurality of journaling processesbased on at least one processing state transition rule, wherein each ofthe plurality of journaling processes controls the queuing, recordingand application of write transactions received at the backup site, andwherein each of the at least one processing state transition rulerelates directly or indirectly to rates of incoming write transactionsat the data backup site, a queue manager coupled with the receiver andthe state machine for temporarily queuing write transactions at thebackup site within a queue until they can be applied, in accordance withthe selected journaling process, and a memory manager coupled with thereceiver and the state machine for recording write transactions at thebackup site, for data recovery purposes, in accordance with the selectedjournaling process, and a storage manager coupled with the receiver andthe state machine for applying the write transactions at the backupsite, in accordance with the selected journaling process.

There is additionally provided in accordance with an embodiment of thepresent invention a computer-readable storage medium storing programcode for causing a computing device to receive a plurality of writetransactions from a data production site, for application at a databackup site, select one of a plurality of journaling processes based onat least one processing state transition rule, wherein each of theplurality of journaling processes controls the queuing, recording andapplication of write transactions received at the backup site, andwherein each of the at least one processing state transition rulerelates directly or indirectly to rates of incoming write transactionsat the data backup site, temporarily queue write transactions at thebackup site within a queue, in accordance with the selected journalingprocess, record write transactions at the backup site, for data recoverypurposes, in accordance with the selected journaling process, and applythe write transactions at the backup site, in accordance with theselected journaling process.

The following definitions are employed throughout the specification andclaims.

BACKUP SITE—a facility where replicated production site data is stored;the backup site may be located in a remote site or at the same locationas the production site;

DPA—a computer or a cluster of computers that serve as a data protectionappliance, responsible for data protection services including inter aliadata replication of a storage system, and journaling of I/O requestsissued by a host computer to the storage system;

HOST—at least one computer or networks of computers that runs at leastone data processing application that issues I/O requests to one or morestorage systems; a host is an initiator with a SAN;

HOST DEVICE—an internal interface in a host, to a logical storage unit;

IMAGE—a copy of a logical storage unit at a specific point in time;

INITIATOR—a node in a SAN that issues I/O requests;

JOURNAL—a record of write transactions issued to a storage system; usedto maintain a duplicate storage system, and to rollback the duplicatestorage system to a previous point in time;

LOGICAL UNIT—a logical entity provided by a storage system for accessingdata from the storage system;

LUN—a logical unit number for identifying a logical unit;

PHYSICAL STORAGE UNIT—a physical entity, such as a disk or an array ofdisks, for storing data in storage locations that can be accessed byaddress;

PRODUCTION SITE—a facility where one or more host computers run dataprocessing applications that write data to a storage system and readdata from the storage system;

SAN—a storage area network of nodes that send and receive I/O and otherrequests, each node in the network being an initiator or a target, orboth an initiator and a target;

SOURCE SIDE—a transmitter of data within a data replication workflow,during normal operation a production site is the source side; and duringdata recovery a backup site is the source side;

STORAGE SYSTEM—a SAN entity that provides multiple logical units foraccess by multiple SAN initiators

TARGET—a node in a SAN that replies to I/O requests;

TARGET SIDE—a receiver of data within a data replication workflow;during normal operation a back site is the target side, and during datarecovery a production site is the target side;

WAN—a wide area network that connects local networks and enables them tocommunicate with one another, such as the Internet.

BRIEF DESCRIPTION OF THE DRAWINGS

The present invention will be more fully understood and appreciated fromthe following detailed description, taken in conjunction with thedrawings in which:

FIG. 1 is a simplified block diagram of a data protection system, inaccordance with an embodiment of the present invention;

FIG. 2 is a simplified illustration of a journal history of writetransactions for a storage system, in accordance with an embodiment ofthe present invention;

FIG. 3A is a simplified illustration of a first stage of a journal andfour data streams stored therein, after recording three writetransactions, in accordance with an embodiment of the present invention;

FIG. 3B is a simplified illustration of a second stage of a journal andfour data streams stored therein, after applying a first writetransactions to a storage system, in accordance with an embodiment ofthe present invention;

FIG. 3C is a simplified illustration of a third stage of a journalhistory and four data streams stored therein, after applying a secondwrite transactions to a storage system, in accordance with an embodimentof the present invention;

FIG. 3D is a simplified illustration of a fourth stage of a journalhistory and four data streams stored therein, after rolling back a writetransaction, in accordance with an embodiment of the present invention;

FIG. 4 is a simplified flowchart of a data protection method during anormal production mode, in accordance with an embodiment of the presentinvention;

FIG. 5 is a simplified flowchart of a data protection method during adata recovery mode, prior to completion of rollback, in accordance withan embodiment of the present invention;

FIG. 6 is a simplified flowchart of a data protection method during adata recovery mode, after completion of rollback, in accordance with anembodiment of the present invention;

FIG. 7 is a simplified illustration of a time-line for tracking newprocessing of old data, in accordance with an embodiment of the presentinvention;

FIG. 8 is a simplified illustration of a five-stage journaling processfor continuous data replication, in accordance with an embodiment of thepresent invention;

FIG. 9 is a simplified illustration of a four-stage journaling processfor continuous data replication, for use when an I/O data rate is low,in accordance with an embodiment of the present invention;

FIG. 10 is a simplified illustration of a three-stage journaling processfor continuous data replication, for use when an I/O data rate is high,in accordance with an embodiment of the present invention;

FIG. 11 is a simplified state diagram of transitions between 5-stage,4-stage and 3-stage journal processing, in accordance with an embodimentof the present invention; and

FIG. 12 is a simplified illustration of a variant of the three-stagejournaling process shown in FIG. 10, which may be used in an alternativeembodiment of the present invention.

DETAILED DESCRIPTION

Reference is now made to FIG. 1, which is a simplified illustration of adata protection system 100, in accordance with an embodiment of thepresent invention. Shown in FIG. 1 are two sites; Site I, which is aproduction site, on the right, and Site II, which is a backup site, onthe left. Under normal operation the production site is the source sideof system 100, and the backup site is the target side of the system. Thebackup site is responsible for replicating production site data.Additionally, the backup site enables rollback of Site I data to anearlier pointing time, which may be used in the event of data corruptionof a disaster, or alternatively in order to view or to access data froman earlier point in time.

During normal operations, the direction of replicate data flow goes fromsource side to target side. It is possible, however, for a user toreverse the direction of replicate data flow, in which case Site Istarts to behave as a target backup site, and Site II starts to behaveas a source production site. Such change of replication direction isreferred to as a “failover”. A failover may be performed in the event ofa disaster at the production site, or for other reasons. In some dataarchitectures, Site I or Site II behaves as a production site for aportion of stored data, and behaves simultaneously as a backup site foranother portion of stored data. In some data architectures, a portion ofstored data is replicated to a backup site, and another portion is not.

The production site and the backup site may be remote from one another,or they may both be situated at a common site, local to one another.Local data protection has the advantage of minimizing data lag betweentarget and source, and remote data protection has the advantage is beingrobust in the event that a disaster occurs at the source side.

The source and target sides communicate via a wide area network (WAN)128, although other types of networks are also adaptable for use withthe present invention.

In accordance with an embodiment of the present invention, each side ofsystem 100 includes three major components coupled via a storage areanetwork (SAN); namely, (i) a storage system, (ii) a host computer, and(iii) a data protection appliance (DPA). Specifically with reference toFIG. 1, the source side SAN includes a source host computer 104, asource storage system 108, and a source DPA 112. Similarly, the targetside SAN includes a target host computer 116, a target storage system120, and a target DPA 124.

Generally, a SAN includes one or more devices, referred to as “nodes”. Anode in a SAN may be an “initiator” or a “target”, or both. An initiatornode is a device that is able to initiate requests to one or more otherdevices; and a target node is a device that is able to reply torequests, such as SCSI commands, sent by an initiator node. A SAN mayalso include network switches, such as fiber channel switches. Thecommunication links between each host computer and its correspondingstorage system may be any appropriate medium suitable for data transfer,such as fiber communication channel links.

In an embodiment of the present invention, the host communicates withits corresponding storage system using small computer system interface(SCSI) commands.

System 100 includes source storage system 108 and target storage system120. Each storage system includes physical storage units for storingdata, such as disks or arrays of disks. Typically, storage systems 108and 120 are target nodes. In order to enable initiators to send requeststo storage system 108, storage system 108 exposes one or more logicalunits (LU) to which commands are issued. Thus, storage systems 108 and120 are SAN entities that provide multiple logical units for access bymultiple SAN initiators.

Logical units are a logical entity provided by a storage system, foraccessing data stored in the storage system. A logical unit isidentified by a unique logical unit number (LUN). In an embodiment ofthe present invention, storage system 108 exposes a logical unit 136,designated as LU A, and storage system 120 exposes a logical unit 156,designated as LU B.

In an embodiment of the present invention, LU B is used for replicatingLU A. As such, LU B is generated as a copy of LU A. In one embodiment,LU B is configured so that its size is identical to the size of LU A.Thus for LU A, storage system 120 serves as a backup for source sidestorage system 108. Alternatively, as mentioned hereinabove, somelogical units of storage system 120 may be used to back up logical unitsof storage system 108, and other logical units of storage system 120 maybe used for other purposes. Moreover, in certain embodiments of thepresent invention, there is symmetric replication whereby some logicalunits of storage system 108 are used for replicating logical units ofstorage system 120, and other logical units of storage system 120 areused for replicating other logical units of storage system 108.

System 100 includes a source side host computer 104 and a target sidehost computer 116. A host computer may be one computer, or a pluralityof computers, or a network of distributed computers, each computer mayinclude inter alia a conventional CPU, volatile and non-volatile memory,a data bus, an I/O interface, a display interface and a networkinterface. Generally a host computer runs at least one data processingapplication, such as a database application and an e-mail server.

Generally, an operating system of a host computer creates a host devicefor each logical unit exposed by a storage system in the host computerSAN. A host device is a logical entity in a host computer, through whicha host computer may access a logical unit. In an embodiment of thepresent invention, host device 104 identifies LU A and generates acorresponding host device 140, designated as Device A, through which itcan access LU A. Similarly, host computer 116 identifies LU B andgenerates a corresponding device 160, designated as Device B.

In an embodiment of the present invention, in the course of continuousoperation, host computer 104 is a SAN initiator that issues I/O requests(write/read operations) through host device 140 to LU A using, forexample, SCSI commands. Such requests are generally transmitted to LU Awith an address that includes a specific device identifier, an offsetwithin the device, and a data size. Offsets are generally aligned to 512byte blocks. The average size of a write operation issued by hostcomputer 104 may be, for example, 10 kilobytes (KB); i.e., 20 blocks.For an I/O rate of 50 megabytes (MB) per second, this corresponds toapproximately 5,000 write transactions per second.

System 100 includes two data protection appliances, a source side DPA112 and a target side DPA 124. A DPA performs various data protectionservices, such as data replication of a storage system, and journalingof I/O requests issued by a host computer to source side storage systemdata. As explained in detail hereinbelow, when acting as a target sideDPA, a DPA may also enable rollback of data to an earlier point in time,and processing of rolled back data at the target site. Each DPA 112 and124 is a computer that includes inter alia one or more conventional CPUsand internal memory.

For additional safety precaution, each DPA is a cluster of suchcomputers. Use of a cluster ensures that if a DPA computer is down, thenthe DPA functionality switches over to another computer. The DPAcomputers within a DPA cluster communicate with one another using atleast one communication link suitable for data transfer via fiberchannel or IP based protocols, or such other transfer protocol. Onecomputer from the DPA cluster serves as the DPA leader. The DPA clusterleader coordinates between the computers in the cluster, and may alsoperform other tasks that require coordination between the computers,such as load balancing.

In the architecture illustrated in FIG. 1, DPA 112 and DPA 124 arestandalone devices integrated within a SAN. Alternatively, each of DPA112 and DPA 124 may be integrated into storage system 108 and storagesystem 120, respectively, or integrated into host computer 104 and hostcomputer 116, respectively. Both DPAs communicate with their respectivehost computers through communication lines such as fiber channels using,for example, SCSI commands.

In accordance with an embodiment of the present invention, DPAs 112 and124 are configured to act as initiators in the SAN; i.e., they can issueI/O requests using, for example, SCSI commands, to access logical unitson their respective storage systems. DPA 112 and DPA 124 are alsoconfigured with the necessary functionality to act as targets; i.e., toreply to I/O requests, such as SCSI commands, issued by other initiatorsin the SAN, including inter alia their respective host computers 104 and116. Being target nodes, DPA 112 and DPA 124 may dynamically expose orremove one or more logical units.

As described hereinabove, Site I and Site II may each behavesimultaneously as a production site and a backup site for differentlogical units. As such, DPA 112 and DPA 124 may each behave as a sourceDPA for some logical units, and as a target DPA for other logical units,at the same time.

In accordance with an embodiment of the present invention, host computer104 and host computer 116 include protection agents 144 and 164,respectively. Protection agents 144 and 164 intercept SCSI commandsissued by their respective host computers, via host devices to logicalunits that are accessible to the host computers. In accordance with anembodiment of the present invention, a data protection agent may act onan intercepted SCSI commands issued to a logical unit, in one of thefollowing ways:

Send the SCSI commands to its intended logical unit.

Redirect the SCSI command to another logical unit.

Split the SCSI command by sending it first to the respective DPA. Afterthe DPA returns an acknowledgement, send the SCSI command to itsintended logical unit.

Fail a SCSI command by returning an error return code.

Delay a SCSI command by not returning an acknowledgement to therespective host computer.

A protection agent may handle different SCSI commands, differently,according to the type of the command. For example, a SCSI commandinquiring about the size of a certain logical unit may be sent directlyto that logical unit, while a SCSI write command may be split and sentfirst to a DPA associated with the agent. A protection agent may alsochange its behavior for handling SCSI commands, for example as a resultof an instruction received from the DPA.

Specifically, the behavior of a protection agent for a certain hostdevice generally corresponds to the behavior of its associated DPA withrespect to the logical unit of the host device. When a DPA behaves as asource site DPA for a certain logical unit, then during normal course ofoperation, the associated protection agent splits I/O requests issued bya host computer to the host device corresponding to that logical unit.Similarly, when a DPA behaves as a target device for a certain logicalunit, then during normal course of operation, the associated protectionagent fails I/O requests issued by host computer to the host devicecorresponding to that logical unit.

Communication between protection agents and their respective DPAs mayuse any protocol suitable for data transfer within a SAN, such as fiberchannel, or SCSI over fiber channel. The communication may be direct, orvia a logical unit exposed by the DPA. In an embodiment of the presentinvention, protection agents communicate with their respective DPAs bysending SCSI commands over fiber channel.

In an embodiment of the present invention, protection agents 144 and 164are drivers located in their respective host computers 104 and 116.Alternatively, a protection agent may also be located in a fiber channelswitch, or in any other device situated in a data path between a hostcomputer and a storage system.

What follows is a detailed description of system behavior under normalproduction mode, and under recovery mode.

In accordance with an embodiment of the present invention, in productionmode DPA 112 acts as a source site DPA for LU A. Thus, protection agent144 is configured to act as a source side protection agent; i.e., as asplitter for host device A. Specifically, protection agent 144replicates SCSI I/O requests. A replicated SCSI I/O request is sent toDPA 112. After receiving an acknowledgement from DPA 124, protectionagent 144 then sends the SCSI I/O request to LU A. Only after receivinga second acknowledgement from storage system 108 will host computer 104initiate another I/O request.

When DPA 112 receives a replicated SCSI write request from dataprotection agent 144, DPA 112 transmits certain I/O informationcharacterizing the write request, packaged as a “write transaction”,over WAN 128 to DPA 124 on the target side, for journaling and forincorporation within target storage system 120.

DPA 112 may send its write transactions to DPA 124 using a variety ofmodes of transmission, including inter alia (i) a synchronous mode, (ii)an asynchronous mode, and (iii) a snapshot mode. In synchronous mode,DPA 112 sends each write transaction to DPA 124, receives back anacknowledgement from DPA 124, and in turns sends an acknowledgement backto protection agent 144. Protection agent 144 waits until receipt ofsuch acknowledgement before sending the SCSI write request to LU A.

In asynchronous mode, DPA 112 sends an acknowledgement to protectionagent 144 upon receipt of each I/O request, before receiving anacknowledgement back from DPA 124.

In snapshot mode, DPA 112 receives several I/O requests and combinesthem into an aggregate “snapshot” of all write activity performed in themultiple I/O requests, and sends the snapshot to DPA 124, for journalingand for incorporation in target storage system 120. In snapshot mode DPA112 also sends an acknowledgement to protection agent 144 upon receiptof each I/O request, before receiving an acknowledgement back from DPA124.

For the sake of clarity, the ensuing discussion assumes that informationis transmitted at write-by-write granularity.

While in production mode, DPA 124 receives replicated data of LU A fromDPA 112, and performs journaling and writing to storage system 120. Whenapplying write operations to storage system 120, DPA 124 acts as aninitiator, and sends SCSI commands to LU B.

During a recovery mode, DPA 124 undoes the write transactions in thejournal, so as to restore storage system 120 to the state it was at, atan earlier time.

As described hereinabove, in accordance with an embodiment of thepresent invention, LU B is used as a backup of LU A. As such, duringnormal production mode, while data written to LU A by host computer 104is replicated from LU A to LU B, host computer 116 should not be sendingI/O requests to LU B. To prevent such I/O requests from being sent,protection agent 164 acts as a target site protection agent for hostDevice B and fails I/O requests sent from host computer 116 to LU Bthrough host Device B.

In accordance with an embodiment of the present invention, targetstorage system 120 exposes a logical unit 176, referred to as a “journalLU”, for maintaining a history of write transactions made to LU B,referred to as a “journal”. Alternatively, journal LU 176 may be stripedover several logical units, or may reside within all of or a portion ofanother logical unit. DPA 124 includes a journal processor 180 formanaging the journal.

Journal processor 180 functions generally to manage the journal entriesof LU B. Specifically, journal processor 180 (i) enters writetransactions received by DPA 124 from DPA 112 into the journal, bywriting them into the journal LU, (ii) applies the journal transactionsto LU B, and (iii) updates the journal entries in the journal LU withundo information and removes already-applied transactions from thejournal. As described below, with reference to FIGS. 2 and 3A-3D,journal entries include four streams, two of which are written whenwrite transaction are entered into the journal, and two of which arewritten when write transaction are applied and removed from the journal.

Reference is now made to FIG. 2, which is a simplified illustration of awrite transaction 200 for a journal, in accordance with an embodiment ofthe present invention. The journal may be used to provide an adaptor foraccess to storage 120 at the state it was in at any specified point intime. Since the journal contains the “undo” information necessary torollback storage system 120, data that was stored in specific memorylocations at the specified point in time may be obtained by undoingwrite transactions that occurred subsequent to such point in time.

Write transaction 200 generally includes the following fields:

one or more identifiers;

a time stamp, which is the date & time at which the transaction wasreceived by source side DPA 112;

a write size, which is the size of the data block;

a location in journal LU 176 where the data is entered;

a location in LU B where the data is to be written; and

the data itself.

Write transaction 200 is transmitted from source side DPA 112 to targetside DPA 124. As shown in FIG. 2, DPA 124 records the write transaction200 in four streams. A first stream, referred to as a DO stream,includes new data for writing in LU B. A second stream, referred to asan DO METADATA stream, includes metadata for the write transaction, suchas an identifier, a date & time, a write size, a beginning address in LUB for writing the new data in, and a pointer to the offset in the dostream where the corresponding data is located. Similarly, a thirdstream, referred to as an UNDO stream, includes old data that wasoverwritten in LU B; and a fourth stream, referred to as an UNDOMETADATA, include an identifier, a date & time, a write size, abeginning address in LU B where data was to be overwritten, and apointer to the offset in the undo stream where the corresponding olddata is located.

In practice each of the four streams holds a plurality of writetransaction data. As write transactions are received dynamically bytarget DPA 124, they are recorded at the end of the DO stream and theend of the DO METADATA stream, prior to committing the transaction.During transaction application, when the various write transactions areapplied to LU B, prior to writing the new DO data into addresses withinthe storage system, the older data currently located in such addressesis recorded into the UNDO stream.

By recording old data, a journal entry can be used to “undo” a writetransaction. To undo a transaction, old data is read from the UNDOstream in a reverse order, from the most recent data to the oldest data,for writing into addresses within LU B. Prior to writing the UNDO datainto these addresses, the newer data residing in such addresses isrecorded in the DO stream.

The journal LU is partitioned into segments with a pre-defined size,such as 1 MB segments, with each segment identified by a counter. Thecollection of such segments forms a segment pool for the four journalingstreams described hereinabove. Each such stream is structured as anordered list of segments, into which the stream data is written, andincludes two pointers—a beginning pointer that points to the firstsegment in the list and an end pointer that points to the last segmentin the list.

According to a write direction for each stream, write transaction datais appended to the stream either at the end, for a forward direction, orat the beginning, for a backward direction. As each write transaction isreceived by DPA 124, its size is checked to determine if it can fitwithin available segments. If not, then one or more segments are chosenfrom the segment pool and appended to the stream's ordered list ofsegments.

Thereafter the DO data is written into the DO stream, and the pointer tothe appropriate first or last segment is updated. Freeing of segments inthe ordered list is performed by simply changing the beginning or theend pointer. Freed segments are returned to the segment pool for re-use.

When a write transaction is received, journaling is thus advanced asindicated in TABLE I below.

TABLE I Entering a write transaction in the journal Step 1 The new datais written at the end of the DO stream, assuming a forward writedirection, and corresponding metadata is written at the end of the DOMETADATA stream. Step 2 Data is read from the beginning of the DOstream, and corresponding metadata is read from the beginning of the DOMETADATA stream. Step 3 Old data to be overwritten is read from LU B.The location and size of such old data is determined from the DOMETADATA stream. Step 4 The old data is written at the end of the UNDOstream, and corresponding metadata is written at the end of the UNDOMETADATA stream. Step 5 The new data read at Step 2 is written into LUB, and the beginning and end pointers of the DO and DO METADATA streamsare moved appropriately.

Conversely, during a rollback to undo a write transaction, the aboveoperations are reversed, as indicated in TABLE II below.

TABLE II Undoing a write transaction in the journal Step 1 Read the dataand metadata from the end of the UNDO and UNDO METADATA streams. Step 2Read from LU B the data that is to be overwritten. The location and sizeof such data is determined from the UNDO METADATA stream. Step 3 Writethe data from Step 2 at the beginning of the DO stream, and update theDO METADATA stream accordingly. Step 4 Write the data from Step 1 to LUB, and update the beginning and end pointers of the UNDO and UNDOmetadata streams appropriately.

The following example, in conjunction with FIGS. 3A-3D, describesspecific details of the journaling process, in accordance with anembodiment of the present invention. A journal volume includes aplurality of segments from a segment pool, each segment including 20data blocks.

Three write transactions are received, as indicated in TABLE III.

TABLE III Example Write Transactions Journal Write ID Time LU B locationLength LU location 1 Dec. 3, 2005 LU B 15 blocks Segment 1, 10:00:00.00offset 57 blocks offset 0 2 Dec. 3, 2005 LU B 20 blocks Segment 1,10:00:00.05 offset 87 blocks offset 15 3 Dec. 3, 2005 LU B 20 blocksSegment 3, 10:00:00.18 offset 12 blocks Offset 15

The following discussion describes four stages of journaling and datastorage; namely,

Stage #1: Enter the three write transactions as journal entries in thejournal LU.

Stage #2: Apply the first write transaction to LU B.

Stage #3: Apply the second write transaction to LU B.

Stage #4: Rollback the second write transaction, to recover data from anearlier point in time.

The write transaction with ID=1 is written to the first 15 blocks ofSegment #1. The metadata corresponding to this transaction is written tothe first block of Segment #2. The second write transaction with ID=2 iswritten to the last 5 blocks of Segment #1 and the first 15 blocks ofSegment #3. The metadata corresponding to this transaction is written tothe second block of Segment #2. The third write transaction with ID=3 iswritten to the last 5 blocks of Segment #3 and the first 15 blocks ofSegment #4. The metadata corresponding to this transaction is written tothe third block of Segment #2.

Thus at stage #1, the DO stream in memory includes a list of segments 1,3, 4; and a beginning pointer to offset=0 in Segment #1 and an endpointer to offset=10 in Segment #4. The DO METADATA stream in memoryincludes a list of one segment, namely Segment #2; and a beginningpointer to offset=0 in Segment #2 and an end pointer to offset=3 inSegment #2. The UNDO stream and the UNDO METADATA stream are empty. Thejournal and the four streams at the end of stage #1 are illustrated inFIG. 3A.

At stage #2 the write transaction with ID=1 is applied to LU B. New datato be written is read from the journal LU at the offset and lengthindicated in the DO METADATA; namely, 15 blocks of data located inblocks 0-14 of journal volume Segment #1. Correspondingly, old data isread from LU B at the offset and length indicated in the UNDO METADATA;namely, 15 blocks of data located in blocks 57-71 of LU B. The old datais then written into the UNDO stream in the journal LU, and theassociated metadata is written into the UNDO METADATA stream in thejournal LU. Specifically, for this example, the UNDO data is writteninto the first 15 blocks of Segment #5, and the UNDO METADATA is writteninto the first block of Segment #6. The beginning pointer of the UNDOdata stream is set to offset=0 in Segment #5, and the end pointer is setto offset=15 in Segment #5. Similarly, the beginning pointer of the UNDOMETADATA stream is set to offset=0 on Segment #6, and the end pointer isset to offset=1 in Segment #6.

At this point, the new data that was read from blocks 0-14 of journal LUSegment #1 is written to blocks 57-71 of LU B. The beginning pointer forthe DO stream is moved forward to block 15 of journal LU Segment #1, andthe beginning pointer for the DO METADATA stream is moved forward toblock 1 of journal LU Segment #2. The journal and the four streams atthe end of stage #2 are illustrated in FIG. 3B.

At stage #3 the write transaction with ID=2 is applied to the storagesystem. As above, 20 blocks of new data are read from blocks 15-19 ofjournal LU Segment #1 and from blocks 0-14 of journal LU Segment #3.Similarly, 20 blocks of old data are read from blocks 87-106 of LU B.The old data is written to the UNDO stream in the last 5 blocks ofjournal LU Segment #5 and the first 15 blocks of journal LU Segment #7.The associated metadata is written to the UNDO METADATA stream in thesecond block of Segment #6. The list of segments in the UNDO streamincludes Segment #5 and Segment #7. The end pointer of the UNDO streamis moved to block 15 of Segment #7, and the end pointed of the UNDOMETADATA stream is moved to block 2 of Segment #6.

Finally, the new data from blocks 15-19 of journal LU Segment #1 andblocks 0-14 of journal LU Segment #3 is written into blocks 87-106 of LUB. The beginning pointer for the DO stream is moved forward to block 15of journal volume Segment #3, and the beginning pointer for the DOMETADATA stream is moved forward to block 2 of journal LU Segment #2.Segment #1 is freed from the DO stream, for recycling within the segmentpool, and the list of segments for the DO stream is changed to Segment#3 and Segment #4. The journal and the four streams at the end of stage#3 are illustrated in FIG. 3C.

At stage #4 a rollback to time 10:00:00.00 is performed. Since the writetransaction with ID=3 was not applied yet, the only write transaction tobe undone is the write transaction with ID=2. The last entry is readfrom the UNDO METADATA stream, the location of the end of the UNDOMETADATA stream being determined by its end pointer, i.e., the metadatabefore block 2 of journal LU Segment #6 is read, indicating two areaseach of 20 blocks; namely, (a) the last 5 blocks of journal LU Segment#5 and the first 15 blocks of journal LU Segment #7, and (b) blocks87-106 of LU B. Area (a) is part of the UNDO stream.

The 20 blocks of data from area (b) are read from LU B and written tothe beginning of the DO stream. As the beginning pointer of the DOstream is set to offset=15 of journal LU Segment #3, 5 blocks arewritten at the end of Segment #3, and the remaining 15 blocks arewritten to Segment #8. The end pointer for the DO stream is set to block15 of Segment #8. The list of segments for the DO stream is changed toSegment #3, Segment #4 and Segment #8. The metadata associated with the20 blocks from area (b) is written to block 3 of Segment #2, and the endpointer of the DO METADATA stream is advanced to block 4 of Segment #2.

The 20 blocks of data in area (a) of the journal LU are then written toarea (b) of the LU B. Finally, Segment #7 is freed for recycling in thesegment pool, the UNDO stream ending pointer is moved back to Segment #5of the journal LU, block 15, and the UNDO METADATA stream ending pointedis moved back to Segment #6 of the journal LU, block 1. The journal andthe four streams at the end of stage #4 are illustrated in FIG. 3D.

Thus it may be appreciated that the journal is thus used to rollback LUB to the state that it was in at a previous point in time. The journalis also used to selectively access data from LU B at such previous pointin time, without necessarily performing a rollback. Selective access isuseful for correcting one or more files that are currently corrupt, orfor simply accessing old data.

TABLE IV below summarizes the behavior of the special protectioncomponents of system 100 during production mode. Reference is also madeto FIG. 4, which is a simplified flowchart of a data protection methodcorresponding to TABLE IV. FIG. 4 is divided into four columns. Theleftmost column indicates steps performed by source side protectionagent 112, the middle left column indicates steps performed by sourceside DPA 144, the middle right column indicates steps performed bytarget side DPA 124, and the rightmost column indicates steps performedby target side protection agent 164.

TABLE IV Normal Production Mode Functionality System Component BehaviorSource Side Intercept SCSI commands issued to LU A by Agent 144 sourceside host via Device A (step 404). Replicate write commands, and routewrite commands to DPA (steps 408 and 412). Wait for firstacknowledgement, from DPA (step 416), and then route replicate I/Ocommand to LU A (step 420). Wait for second acknowledgement, fromstorage system (step 424), and then process next intercepted SCSIcommand (step 404). Source Side Receive write command from agent (step428). DPA 112 Format write command as write transaction, and send totarget DPA (step 428). In synchronous mode, wait for acknowledgementfrom target DPA (step 432), and then send acknowledgement to agent (step436). In asynchronous mode and in snapshot mode, send acknowledgement toagent without waiting for acknowledgement from target DPA (step 436).Target Side Receive write transaction from source DPA (step DPA 124444). Enter write transaction in journal DO and DO METADATA streams(step 444), and send back acknowledgement to source DPA (step 448).Process journal entries by applying them to LU B, and enter undoinformation in UNDO and UNDO METADATA streams (step 440). Target SideFail SCSI commands issued to LU B (step 452). Agent 164

Only steps with arrows connecting them in FIG. 4 are necessarilysequential. Thus steps 432 and 436, which do not have arrows connectingthem, are not necessarily sequential. In synchronous mode these stepsare sequential, but in asynchronous mode and in snapshot mode they arenot sequential. In particular, DPA 112 may send an acknowledgement toprotection agent 144 before receiving an acknowledgement back from DPA124.

It is also noted in FIG. 4 that the steps performed by target side DPA124 include two non-sequential groups; namely, (i) step 440, and (ii)steps 444 and 448.

Recovery mode is generally triggered as a result of a disaster at thesource side. The source side data may become corrupt, or may not existat all. In such case, after recovery is completed at the backup site, auser may perform a failover operation by switching the roles of theproduction site and backup site. The original backup site becomes acurrent production site, and the original production site becomes acurrent backup site. Alternatively, recovery mode can be triggeredwithout a failover, in order to access data from a previous point intime.

While in recovery mode, target site DPA 124 continues to receive newwrite transactions from DPA 112 and enter them at the ends of the DO andDO METADATA streams. However, unlike production mode behavior, DPA 124stops applying journal entries received from DPA 112 to LU B. Instead,DPA 124 uses the UNDO stream of the journal to rollback LU B, asdescribed hereinabove.

During recovery, after or possibly before rollback of LU B is complete,a user may wish to access data from the target site. To this end,protection agent 164 stops failing I/O requests issued by host computer160 and begins redirecting them to DPA 124. The processing of data byhost computer 160 during recovery mode is referred to as “target sideprocessing (TSP)”.

To manage TSP write commands that are received by target side DPA 124,journal processor 180 uses two additional data streams, referred to asTSP DO and TSP METADATA streams. When a TSP write command is received byDPA 124, it is entered at the end of the TSP DO stream and the end ofthe TSP DO METADATA stream. Since TSP writes relate to the state of LU Bafter the rollback is complete, the TSP DO stream writes are onlyapplied to LU B after rollback is complete. Journal processor 180applies TSP writes to LU B in a way similar to the way it applies writetransactions deceiver from DPA 112; namely, journal processor 180maintains the undo information for each write applied to LU B, in TSPUNDO and TSP UNDO METADATA streams.

When TSP read commands are received by target site DPA 124, DPA 124returns the data to be read by identifying locations of the readcommand, and finding the most recent TSP write command or commands thatwere applied at these locations. The data is searched for (i) first inthe TSP DO stream, and (ii) then in the journal UNDO data that was notyet applied to LU B and (iii) finally, if the data was not found in (i)and (ii), then the data is taken from LU B itself. In order to performsuch a search efficiently, DPA 124 generates and stores in its memory avirtual image of the UNDO METADATA storage locations by using anefficient data structure, such as a binary search tree.

After rollback is completed, the TSP writes that were performed duringthe rollback are applied to LU B, and DPA 124 begins applying TSP writessynchronously; i.e., TSP writes are applied to LU B when they arereceived by DPA 124, without keeping them in the TSP DO stream. As such,when a read command is received after rollback is complete, it is sentdirectly to LU B instead of being redirected through DPA 124.

TABLES V and VI below summarize the behavior of the special protectioncomponents of system 100 during recovery mode, before and after therollback is complete, in accordance with an embodiment of the presentinvention. Reference is also made to FIGS. 5 and 6, which are simplifiedflowcharts of data protection methods corresponding to TABLES V and VI,respectively. FIGS. 5 and 6 are divided into four columns. The leftmostcolumn indicates steps performed by target side protection agent 164,the middle left column indicates steps performed by target side DPA 124,the middle right column indicates steps performed by source side DPA112, and the rightmost column indicates steps performed by source sideprotection agent 144.

TABLE V Recovery Functionality prior to Completion of Rollback SystemComponent Behavior Target Side Intercept SCSI commands issued to LU B(step Agent 164 576). Redirect commands to DPA (step 580). Target SideUse UNDO stream of journal to roll back target DPA 124 storage system(step 540). Continue receiving write transactions from DPA 112 and enterthese transactions into DO and DO METADATA streams without applying themto LU B (step 548). Enter TSP write transactions to TSP DO and TSP DOMETADATA streams (step 564). Create a virtual image, to reply to readcommands issued during the recovery process (step 572). Source Side Asin production mode. DPA 112 Source Side As in production mode. Agent 144

TABLE VI Recovery Functionality after Completion of Rollback SystemComponent Behavior Target Side Intercept SCSI commands issued to LU B(step Agent 164 664). Redirect write transactions to DPA (step 672), androute read commands directly to LU B (step 680). Target Side Apply TSPwrite transactions to LU B, in the same DPA 124 manner that writetransactions received from DPA 112 are applied in production mode; i.e.,by entering data into TSP UNDO and TSP UNDO METADATA streams (step 640).Enter DO information and write transactions received from DPA 112 intoDO and DO METADATA streams, without applying them to LU B (step 644).Apply TSP write transactions to LU B as they are received (step 656).Source Side As in production mode. DPA 112 Source Side As in productionmode. Agent 144

It is also noted in FIG. 5 that the steps performed by target side DPA124 include three non-sequential groups; namely, (i) step 540, (i) steps548 and 552, and (iii) steps 556, 560, 564, 568 and 572. Similarly inFIG. 6 target side DPA performs three non-sequential groups of steps;namely, (i) step 640, (ii) steps 644 and 648, and (iii) steps 652, 656and 660.

Reference is now made to FIG. 7, which is a simplified illustration of atime-line for tracking new processing of old data, in accordance with anembodiment of the present invention. FIG. 7 illustrates journalprocessor 180 bringing the timeline back to a previous time, TOLD, andjournal processor 180 applying TSP writes to bring the timeline forwardfrom time TCURRENT to time TNEW. As shown in FIG. 7, current data attime (1) is rolled back to old data at time (2). After rolling back thedata to time (2), the rolled back data becomes the image upon whichtarget side processing advances to new data at time (3); i.e., thetarget side processing is applied to data (2) and not to data (1).

The data at time (1) is a common image for LU A and LU B at the samepoint in time, TCURRENT. Similarly, the data at time (2) is a commonimage for LU A and LU B at time TOLD. Rolled back data at time (2) maybe processed by TSP writes, while at the same time current data at time(1) is being processed by source side writes. As such, the data evolvesalong the path from time (2) to time (3) as it is processed by thetarget side, and along the path from time (2) to time (4) as it isprocessed by the source side. The data images at the source and targetsides at time TNEW are thus different.

When the recovery process is completed, the user may (i) return to anormal production mode, or (ii) perform a failover by switching thereplication direction. In case (i), LU B is rolled back to its state attime (2), and the write transactions along the path from (2) to (4) areapplied to LU B, so as to bring LU B to the same image as LU A.Conversely, in case (ii), LU B is maintained at its state at time (3),and its data is copied from the target side to the source side so as tobring LU A to the same image as LU B.

It may be appreciated that after rolling back the UNDO data stream to LUB, the state of the target side storage is substantially identical tothe state that LU A was in at an earlier point in time. However, afterapplying TSP writes, the state of LU B is then in a new state that isdifferent from the earlier state of LU A. As such, in order to return toa normal production mode, and ensure that LU B is a copy of LU A, DPA124 undoes the TSP writes that were written to LU B using the TSP undostream, and then returns to its normal production mode and beginsapplying the data that was written into the DO stream. The DO streamincludes all write transactions that were undone while LU B was rolledback. Additionally, the DO stream includes new journal entries that werereceived from DPA 112 while DPA was in recovery mode. Similarly,protection agent 164 returns to its production mode by beginning to failI/O requests issued by host 116.

Alternatively, the user want to perform a failover; i.e., to make LU Bin its current state a production LU and ensure that LU A is a copy ofLU B. In this case the write transactions in the DO stream thatcorrespond to a point in time subsequent to the recovered point in timeare ignored. Additionally, the TSP writes that were applied to LU Bduring the recovery process are applied to LU A. Thereafter, thereplication direction changes. Specifically, DPA 124 and protectionagent 164 begin behaving in accordance with source site behavior, andDPA 112 and protection agent 144 begin behaving in accordance withtarget site behavior.

It may be appreciated that in order to provide failover capability, inwhich the roles of the production site and the backup site are switched,it is desirable that the source side has the necessary system componentsto function as a target side, and vice versa. Thus, in an embodiment ofthe present invention, the source side includes its own journal LU 184and journal processor 188, as indicated with dotted lines in FIG. 1.

Referring back to TABLE I, it may be appreciated that during normal datareplication, for each write transaction received from a production site,there are five I/O operations performed at a backup site. Reference isnow made to FIG. 8, which is a simplified illustration of a 5-stagejournaling process for continuous data replication, in accordance withan embodiment of the present invention. The five steps shown in FIG. 8correspond respectively to the five steps listed in TABLE I. For thesake of clarity, FIG. 8 only shows three meta-data elements; namely, asize, a journal address and a storage address. It may be appreciatedthat the meta-data in the DO METADATA and UNDO METADATA streams includesan ID, a time, and other attributes.

In accordance with an embodiment of the present invention, the meta-datafor each transaction is of a fixed size, typically 30 bytes. The rawdata varies in size, typically averaging around 10 KB per transaction.

As write transactions performed at a production site vary in frequency,and as each write transaction at the production site normally requiresfive I/O transactions at the backup site, it may be appreciated that thesize of the DO stream grows and shrinks accordingly. When the I/O rateis low, the beginning of the DO stream is close to the end of the DOstream. In such case, it is possible to keep all write transactionsbetween the beginning and the end of the DO stream in memory, and thereis no need to read the beginning of the DO stream for every newtransaction received in the backup site. As such, step 2 may be skipped.

Reference is now made to FIG. 9, which is a simplified illustration of a4-stage journaling process for continuous data replication, for use whenan I/O data rate is low, in accordance with an embodiment of the presentinvention. The first step in FIG. 9 copies the write transaction to theend of the DO stream and the end of the DO METADATA stream, as in the5-stage journaling process. Unlike, the 5-stage journaling process,though, instead of reading write transaction data from the beginning ofthe DO and DO METADATA streams, the 4-stage journaling process takesadvantage of the fact that the write transaction that was just receivedat the backup site is still resident in memory. For this writetransaction, steps 3-5 are performed, as indicated in FIG. 9.

However, during the steps 3-5 distribution of the write transaction thatwas just received, it is possible that a new transaction arrives at thebackup site. In order to keep pace with the arriving transaction, aseach write transaction is entered into the ends of the DO and DOMETADATA streams, the write transaction is written into the end of aqueue in memory. In accordance with an embodiment of the presentinvention, the queue in memory is handled similar to the way the DOstream is handled; namely, each received write is appended to the end ofthe queue, and when a write transaction is distributed according tosteps 3-5, a subsequent write transaction is taken from the beginning ofthe queue. Effectively, the queue corresponds to a cached DO stream.

The 4-stage journaling process is used until the queue in memory isfull, at which point the normal 5-stage journal processing is resumed.Also in the event of a disaster, the normal 5-stage journal processingis resumed. In order to resume the 5-stage journal processing, it isimportant to identify the last write in the DO stream that was written.As such, even during the 4-stage journal processing, the pointers to thefirst and last write transactions in the DO stream are updated.

Conversely, when the I/O rate is high, in order to control the size ofthe DO stream and ensure that it does not overflow its disk allotment,the present invention switches from the normal 5-stage mode to a faster3-stage mode whenever the DO stream reaches a large percentage of itsmaximum capacity, typically 80%. The present invention afterwardsswitches back from the faster 3-stage mode to the normal 5-stage modewhenever the DO stream is reduced to a smaller percentage of its maximumcapacity, typically 75%.

The 3-stage mode eliminates steps 3 and 4 from the normal mode; namely,the steps that record the UNDO information. As such, rollback of thebackup storage unit to its state at the times of those transactionsprocessed with the 3-stage mode is not possible.

Reference is now made to FIG. 10, which is a simplified illustration ofa 3-stage journaling process for continuous data replication, for usewhen the DO stream is near its maximum capacity, in accordance with anembodiment of the present invention.

TABLE VII summarizes the relative pros and cons of each of thejournaling processes described hereinabove.

TABLE VII Pros and Cons of Journaling Processes Journaling Process ProsCons 3-Stage Fastest replication time Long time to recover to Journalingcurrent time 4-Stage Moderate replication time; Only able to be used aslong Journaling Full data recovery capability as the beginning and theend of the DO stream are close 5-Stage Full data recovery capabilitySlowest replication time Journaling

One data replication strategy is the set of automated rules forcontrolling when a data replication system transitions between 5-stage,4-stage and 3-stage journal processing. As mentioned hereinabove,transitions from 5-stage to 3-stage journaling, and from 3-stage back to5-stage journaling, may be controlled based on the current size of theDO stream. Transitions from 5-stage to 4-stage journaling may beautomated to occur when the beginning and end of the DO stream areclose; and transitions from 4-stage back to 5-stage journaling may beautomated to occur when the memory queue reaches its capacity.

Reference is now made to FIG. 11, which is a simplified state diagram oftransitions between 5-stage, 4-stage and 3-stage journal processing, inaccordance with an embodiment of the present invention. Shown in FIG. 11are three nodes, representing each of the journaling processes, anddirected edges between the nodes corresponding to rules that governtransitions therebetween. As shown in FIG. 11, a 5-stage to 3-stagetransition occurs when the size of the DO stream exceeds 80% of itsallotted capacity, and a 3-stage to 5-stage transition occurs when thesize of the DO stream falls under 75% of its allotted capacity.Similarly, a 5-stage to 4-stage transition occurs when the beginning andend of the DO stream are close; and a 4-stage to 5-stage transitionoccurs when the memory queue reaches its capacity.

It will be appreciated by those skilled in the art that using 4-stagejournaling enables a data replication system to keep pace with higherI/O rates than can be handled when using 5-stage journaling. If thesystem is currently using 5-stage journaling and the I/O rate is higherthan can be handled, a lag increases until the system necessarilytransitions to the 3-stage journaling process. However, if the systemcan catch up with the lag, empty the DO stream and transition to a4-stage journaling process, then the system can accommodate higher I/Orates before transitioning back to the 5-stage journaling process.

In this regard, it is noted that in general, if the system cannot keeppace with I/O rates using a 4-stage journaling process, then it mostprobably cannot keep pace using a 5-stage journaling process, and ineither case the system would have to transition to a 3-stage journalingprocess. However, since the I/O rate changes continuously, a transitionfrom 4-stage journaling to 5-stage journaling does not necessarily pushthe system to 3-stage journaling.

Reference is now made to FIG. 12, which is a simplified illustration ofa variant of the three-stage journaling process shown in FIG. 10, whichmay be used in an alternative embodiment of the present invention. Thealternative 3-stage journaling proceeds according to the last threestages of the 4-stage journaling process. That is, the stage of writingto the DO stream is skipped within 4-stage journaling, for thealternative embodiment of 3-stage journaling. When performing 4-stagejournaling, the backup site DPA (element 124 of FIG. 1) can return anacknowledgement to the production site DPA (element 112 of FIG. 1)immediately after the first stage, when the write transaction is writtento the DO stream. However, when performing the alternative 3-stagejournaling, the backup site DPA must wait until the write transaction iswritten to storage, before it can return an acknowledgement to theproduction site DPA. Since the last three stages of 4-stage journalingcan be performed in a separate thread than the thread that performs thefirst stage, the alternative 3-stage journaling may result in a longertime lag between the source and target sites.

Each acknowledgement received by the production site DPA relates to aspecific time, and thus the production site DPA can determine from theacknowledgement the amount of time lag between the backup site and theproduction site. A user may set a control parameter to configure thedata replication system to constrain the time lag between the productionand backup sites. When the time lag constraint is exceeded, the systemregulates the lag by slowing down the production site application. Assuch, the alternative 3-stage journaling will generally hit the time lagconstraint, and thereby cause a slow down in the production siteapplication, more often than will the 4-stage journaling.

In reading the above description, persons skilled in the art willrealize that there are many apparent variations that can be applied tothe methods and systems described. Thus it may be appreciated that, inaddition to data replication systems, the optimal journaling policy ofthe present invention has widespread application to journaling systemsincluding database systems and version control systems.

In the foregoing specification, the invention has been described withreference to specific exemplary embodiments thereof. It will, however,be evident that various modifications and changes may be made to thespecific exemplary embodiments without departing from the broader spiritand scope of the invention as set forth in the appended claims.Accordingly, the specification and drawings are to be regarded in anillustrative rather than a restrictive sense.

1. A method of replicating data, comprising: (a) receiving transactionscomprising write data from a first data site to be backed tip at abackup storage site; (b) writing the write data to a first position in ado data stream; (c) writing metadata for the write data to a firstposition in a do metadata stream, wherein the metadata for the writedata in step (c) comprises a first field to store a size of the writedata, a second field to store an address at which the write data is tobe stored in the backup storage site and a third field to store apointer to an offset in the do data stream where the write data islocated; (d) reading data from a second position in the do data stream;(e) reading metadata from a second position in the do metadata stream;(f) reading data to be overwritten from a logical unit in the backupstorage site, where location and size of the data to be overwritten isdetermined from the do metadata stream; (g) writing the data to beoverwritten to a first position in an undo data stream; (h) writingmetadata for the data to be overwritten to an undo metadata stream, themetadata for the data to be overwritten comprises a first field to storea size of the data to be overwritten, a second field to store an addressat which the data is to be overwritten in the backup storage site and athird field to store a pointer to an offset in the undo data streamwhere the data to be overwritten is located; and (i) writing the writedata to the logical unit in the backup storage site using the secondfield in the do metadata stream.
 2. The method according to claim 1,further including undoing a write transaction by: (j) reading data fromthe first position in the undo data stream and metadata from the firstposition in the undo metadata stream; (k) reading data from the logicalunit in the backup storage site that is to be overwritten, whereinlocation and size of the data is determined from the undo metadatastream; (l) writing the data read from the logical unit in the backupstorage site in step (k) to the second position of the do data stream;(m) updating the do metadata stream; (n) writing the data from the firstposition of the undo data stream to the logical unit in the backupstorage site; and (o) writing the metadata from the first position ofthe undo metadata stream to the logical unit in the backup storage site.3. The method according to claim 1, further including omitting steps (d)and (e) where a number of the write data transactions from the firstdata site to be backed up per unit time is less than a predeterminedamount.
 4. The method according to claim 3, further including performingsteps (d) and (e) again when a queue memory is more than a given percentfull.
 5. The method according to claim 1, further including omittingsteps (f), (g), and (h) when a size of the do data stream is greaterthan a given value.
 6. The method according to claim 1, furtherincluding omitting steps associated with the undo data stream and undometadata stream when the do data stream becomes larger than a givenvalue.
 7. The method according to claim 1, further including providing astate machine to transition between a number of states having a givennumber of processing stages, wherein a first state includes steps(a)-(i); a second state includes omitting steps (d) and (e) where anumber of the write data transactions from the first data site to bebacked up per unit time is less than a predetermined amount; and a thirdstate includes omitting steps (f), (g), and (h) when a size of the dodata stream is greater than a given value.
 8. The method according toclaim 7, wherein the state machine has three nodes.
 9. The methodaccording to claim 1, further including omitting steps (b)-(e) toprovide a state in a state machine for transitioning between a number ofstates having a given number of processing stages.
 10. An article,comprising: a storage medium having stored thereon instructions thatwhen executed by a machine result in the following: (a) receiving writedata transactions from a first data site to be backed up at a backupstorage site; (b) writing the write data to a first position in a dodata stream; (c) writing metadata for the write data to a first positionin a do metadata stream, wherein the metadata for the write data in step(c) comprises a first field to store a size of the write data, a secondfield to store an address at which the write data is to be stored in thebackup storage site and a third field to store a pointer to an offset inthe do data stream where the write data is located; (d) reading datafrom a second position in the do data stream; (e) reading metadata froma second position in the do metadata stream; (f) reading data to beoverwritten from a logical unit in the backup storage site, wherelocation and size of the data to be overwritten is determined from thedo metadata stream; (g) writing the data to be overwritten to a firstposition in an undo data stream; (h) writing metadata for the data to beoverwritten to an undo metadata stream, the undo metadata comprises afirst field to store a size of the data to be overwritten, a secondfield to store an address at which the data is to be overwritten in thebackup storage site and a third field to store a pointer to an offset inthe undo data stream where the data to be overwritten is located; and(i) writing the write data to the logical unit in the backup storagesite using the second field in the do metadata stream.
 11. The articleaccording to claim 10, further including instructions for undoing awrite transaction by: (j) reading data from the first position in theundo data stream and metadata from the first position in the undometadata stream; (k) reading data from logical unit in the backupstorage site that is to be overwritten, wherein location and size of thedata is determined from the undo metadata stream; (l) writing the dataread from the logical unit in the backup storage site in step (k) to thesecond position of the do data stream; (m) updating the do metadatastream; (n) writing the data from the first position of the undo datastream to the logical unit in the backup storage site; and (o) writingthe metadata from the first position of the undo metadata stream to thelogical unit in the backup storage site.
 12. The article according toclaim 10, further including instructions for omitting steps (d) and (e)where a number of the write data transactions from the first data siteto be backed up per unit time is less than a predetermined amount. 13.The article according to claim 12, further including instructions forperforming steps (d) and (e) again when a queue memory is more than agiven percent full.
 14. The article according to claim 10, furtherincluding instructions for omitting steps (f), (g), and (h) when a sizeof the do data stream is greater than a given value.
 15. The articleaccording to claim 10, further including instructions for omitting stepsassociated with the undo data stream and undo metadata stream when thedo data stream becomes larger than a given value.
 16. The articleaccording to claim 10, further including instructions providing a statemachine to transition between a number of states having a given numberof processing stages, wherein a first state includes steps (a)-(i); asecond state includes omitting steps (d) and (e) where a number of thewrite data transactions from the first data site to be backed up perunit time is less than a predetermined amount; and a third stateincludes omitting steps (f), (g), and (h) when a size of the do datastream is greater than a given value.